package com.zretc.controller;

import com.github.pagehelper.PageInfo;
import com.zretc.service.MovieArrangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/movieArrange")
@Controller
public class MovieArrangeController {
    @Autowired
    private MovieArrangeService movieArrangeService;

    @ResponseBody
    @RequestMapping("/movieArrangeByCinema")
    public PageInfo<Map<String,Object>> movieArrangeByCinema(String movieName,
                                                             String hallName,
                                                             String adminId,
                                                             String startTime,
                                                             String pageNum){
        Map<String,String> params = new HashMap<>();
        params.put("movieName",movieName);
        params.put("hallName",hallName);
        params.put("adminId",adminId);
        params.put("startTime",startTime);
        params.put("pageNum",pageNum);
        params.put("pageSize","5");
        PageInfo<Map<String,Object>> pageInfo = movieArrangeService.getAllMovieManageByAdminId(params);
        return pageInfo;
    }
    @ResponseBody
    @RequestMapping("/getAllHallNameByCinema")
    public List<String> getAllHallNameByCinema(String adminId){
        List<String> hallNameList = movieArrangeService.getAllHallNameByAdminId(adminId);
        return hallNameList;
    }

    @ResponseBody
    @RequestMapping("/updateMovieManage")
    public int updateMovieManage(String manageId,
                                 String startTime,
                                 String endTime){
        Map<String,String> params = new HashMap<>();
        params.put("manageId",manageId);
        params.put("startTime",startTime);
        params.put("endTime",endTime);
        int i = movieArrangeService.updateMovieManage(params);
        return i;
    }

    @ResponseBody
    @RequestMapping("/addMovieManage")
    public int addMovieManage(String manageId,
                                 String hallId,
                                 String movieId,
                                 String startTime,
                                 String endTime){
        Map<String,String> params = new HashMap<>();
        params.put("manageId",manageId);
        params.put("hallId",hallId);
        params.put("movieId",movieId);
        params.put("startTime",startTime);
        params.put("endTime",endTime);
        int i = movieArrangeService.addMovieManage(params);
        return i;
    }

}
